<?php


//var_dump($organization->getAuthorized());
		    global $itemType;
			global $itemTopSize;
			global $itemSize;
			global $itemColor;
			global $itemMaterial;
			global $itemSeason;
			global $itemYear;
			global $itemType;
			global $itemDesigner;
			global $organizationType;
			
				$year1= date('Y');
	$month= date('m');
	$date= date('d');
	

$Inv=$organization->getInventory();
$pcodegroup=array();
foreach($Inv as $inventory){
	

	$pcode=$inventory['item']->product_code;
	  $size=$inventory['item']->size;
	
	if (array_key_exists($pcode, $pcodegroup)){
		if (array_key_exists($size, $pcodegroup[$pcode])){
			$pcodegroup[$pcode][$size]->number+=$inventory['number'];
			continue;
		}
		//array_push($pcodegroup['\''.$pcode.'\''],$inventory);
	}
        $pcodegroup[$pcode][$size]=$inventory;

}


$num=count($pcodegroup);
$result="";
 foreach($pcodegroup as $key => $pcode){
 	    // print_r($pcode);
	 
	 
	 //echo "02--------".$pcode['02']['number'];
	// echo "<br><br><br><br><br><br><br><br>";
         	$two=isset($pcode['02']) ? $pcode['02']['number'] :'0';
			$four=isset($pcode['04']) ? $pcode['04']['number'] :'0';
			$six=isset($pcode['06']) ? $pcode['06']['number'] :'0';
			$eight=isset($pcode['08']) ? $pcode['08']['number'] :'0';
			$ten=isset($pcode['10']) ? $pcode['10']['number'] :'0';
			$twelve=isset($pcode['12']) ? $pcode['12']['number'] :'0';
			$f=isset($pcode['f']) ? $pcode['f']['number'] :'0';
			
			$result.="['$key',$two,$four,$six,$eight,$ten,$twelve,$f],";
 }
if($result!=""){
 $result=substr($result,0,-1);
}
  
  $h= 230+100*count($pcodegroup);

?>
 <script type="text/javascript" src="js/jsapi.js"></script>
    <script type="text/javascript">
      google.load('visualization', '1', {packages: ['corechart']});
    </script>
    <script type="text/javascript">
      function drawVisualization() {
        // Create and populate the data table.
        var data = google.visualization.arrayToDataTable([
        	
          ['尺寸', '02', '04', '06','08','10', '12','均码'],
          <?php 
			echo  $result;
		  
          ?>
        ]);
      
        // Create and draw the visualization.
        new google.visualization.BarChart(document.getElementById('visualization<?php $organization->id;?>')).
            draw(data,
                 {title:"<?php echo $organization->name." 库存目前状况"?>",
                  width:800, height:<?php echo $h;?>,
                  vAxis: {title: "生产款号",gridlinesaaa: {color: '#CCC'},titleTextStyle: {color: '#FF0000'}},
                  hAxis: {title: "数量"},
                  animation:{
        		  			duration: 1000,
        					easing: 'out'
      				}
             	}
            );
      }
      
      google.setOnLoadCallback(drawVisualization);
    </script>
	<div class="block">
	<div class="invertedshiftdown">
<ul>
	<?php
	if($organization->type=='s'){
	?>
			<li class="current"><a href="?page=organization_inventory&id=<?php echo $organization->id; ?>">查看货存</a></li>
			<li><a href="?page=organization_sell&id=<?php echo $organization->id; ?>">出售</a></li>
			<li><a href="?page=organization_return&id=<?php echo $organization->id; ?>">退款</a></li>
			<li><a href="?page=organization_distribute&id=<?php echo $organization->id; ?>">分配</a></li>
			<li><a href="?page=organization_distribute_confirm&id=<?php echo $organization->id; ?>">处理待定分配</a></li>
			<li><a href="?page=organization_transaction&id=<?php echo $organization->id; ?>">查看物流记录</a></li>
			<li><a href="?page=organization_sell_record&id=<?php echo $organization->id; ?>">查看销售记录</a></li>
	<?php
	}elseif($organization->type=='w'){
	?>
	       	<li class="current"><a href="?page=organization_inventory&id=<?php echo $organization->id; ?>">查看库存</a></li>
			<li><a href="?page=organization_stack&id=<?php echo $organization->id; ?>">入库</a></li>
			<li><a href="?page=organization_distribute&id=<?php echo $organization->id; ?>">分配</a></li>
			<li><a href="?page=organization_distribute_confirm&id=<?php echo $organization->id; ?>">处理待定分配</a></li>
			<li><a href="?page=organization_transaction&id=<?php echo $organization->id; ?>">查看物流记录</a></li>
			
    <?php
	}
	?>
</ul>




<form id="myform">
<input type="text" class="textinput" /> <input class="submit" type="submit" value="搜索" />
</form>
</div>

<br style="clear: both;" />
<div id= 'content'>
    <div class="isa_info">
		<h4><?php echo $message ?></h4><?php echo $condition ?>
	</div>
	<h2><?php echo $organization->name ?> 信息</h2>
	
	<dt class="W_bgcolor clearfix">
	<strong>基本信息</strong>
	</dt>
	<dd>
	<ul>
		<li>机构名字：<?php echo $organization->name;?></li>
		<li>机构类型：<?php echo $organizationType['w'];?></li>
		<li>描述：<?php echo $organization->des;?></li>
	</ul>
	</dd>
	<hr>
	<strong>管理权限所有者</strong>
	
		<dd>
			<?php
			foreach($organization->getAuthorized() as $u){
			?>
		<ul>	
			<li>用户名：<?php echo $u->name;?> </li>
			<li>权限：<?php echo $u->getAuthorityName();?> </li>
			<li>职位：<?php echo $u->position;?> </li>
		</ul>
		<?php
			}
			?>
		</dd>
		

	<hr>
		<h2><?php echo $organization->name ?>库存显示</h2>
		<?php
      echo $table;
?>
		<br><br>
	    <div id='visualization<?php $organization->id;?>'></div>
	    <br>
		<h4>按条件搜索</h4>
		 <form action="" method="post">

        	
            <div class="element">
             <label class="form">扫描条码</label>
             <input type="text" id="scan_code" name="scan_code" class="text" maxlength="14" size="14"><div class="important">若为空，搜查结果会显示全部条形码</div>
            </div>
            

            
                <div style="clear:both;">

    <div class="element">
             <label class="form">最小数量</label>
             <input type="text" name="minNum" class="text" size="14"><div class="important">若为空，搜查结果会无最小数量限制</div>
            </div>
   <div style="clear:both;">

    <div class="element">
             <label class="form">最大数量</label>
             <input type="text" name="maxNum" class="text" size="14" ><div class="important">若为空，搜查结果会无最大数量限制</div>
            </div>
   <br>
   <div class="element">
<input type="submit" value="递交" />
        <div class="loading"></div>
    </div>
   </form>
<br>
<br>
<br>


   
<div class="clear"></div>
	</div>